package cn.cubic.sys.modular.subjectinfo.controller;

import cn.cubic.core.annotion.BusinessLog;
import cn.cubic.core.enums.LogAnnotionOpTypeEnum;
import cn.cubic.core.pojo.response.ResponseData;
import cn.cubic.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.cubic.sys.modular.subjectinfo.service.SubjectInfoService;
import cn.cubic.sys.modular.subjectinfo.model.param.SubjectInfoParam;

import javax.annotation.Resource;

/**
 * 课程信息表 控制器
 */
@RestController
public class SubjectInfoController {

    @Resource
    private SubjectInfoService subjectInfoService;

    /**
     * 分页查询课程信息表
     */
    @GetMapping("/subjectInfo/page")
    @BusinessLog(title = "课程信息表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(SubjectInfoParam subjectInfoParam) {
        return new SuccessResponseData(subjectInfoService.page(subjectInfoParam));
    }

    /**
     * 获取全部课程信息表
     */
    @GetMapping("/subjectInfo/list")
    @BusinessLog(title = "课程信息表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(SubjectInfoParam subjectInfoParam) {
        return new SuccessResponseData(subjectInfoService.list(subjectInfoParam));
    }

    /**
     * 查看详情课程信息表
     */
    @GetMapping("/subjectInfo/detail")
    @BusinessLog(title = "课程信息表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(SubjectInfoParam.detail.class) SubjectInfoParam subjectInfoParam) {
        return new SuccessResponseData(subjectInfoService.detail(subjectInfoParam));
    }

    /**
     * 添加课程信息表
     */
    @PostMapping("/subjectInfo/add")
    @BusinessLog(title = "课程信息表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(SubjectInfoParam.add.class) SubjectInfoParam subjectInfoParam) {
        subjectInfoService.add(subjectInfoParam);
        return new SuccessResponseData();
    }

    /**
     * 删除课程信息表
     */
    @PostMapping("/subjectInfo/delete")
    @BusinessLog(title = "课程信息表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(SubjectInfoParam.delete.class) SubjectInfoParam subjectInfoParam) {
        subjectInfoService.delete(subjectInfoParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑课程信息表
     */
    @PostMapping("/subjectInfo/edit")
    @BusinessLog(title = "课程信息表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(SubjectInfoParam.edit.class) SubjectInfoParam subjectInfoParam) {
        subjectInfoService.edit(subjectInfoParam);
        return new SuccessResponseData();
    }


}
